import zhHans from './zh-Hans'
import zhHant from './zh-Hant'
import pt from './pt'

export const messages = {
  'zh-Hans': zhHans,
  'zh-Hant': zhHant,
  'pt': pt
}

// 获取系统语言
export function getSystemLanguage() {
  const systemLanguage = uni.getSystemInfoSync().language
  // 根据系统语言返回匹配的语言代码
  if (systemLanguage.includes('zh')) {
    return systemLanguage.includes('Hans') ? 'zh-Hans' : 'zh-Hant'
  }
  return systemLanguage.includes('pt') ? 'pt' : 'zh-Hans'
}

// 获取存储的语言设置
export function getStoredLanguage() {
  return uni.getStorageSync('language') || getSystemLanguage()
}

// 设置语言
export function setLanguage(lang) {
  uni.setStorageSync('language', lang)
} 